//
//  NSError+QNCentral.m
//  QNCentralModule_iOS
//
//  Created by donyau on 2018/11/5.
//  Copyright © 2018 Yolanda. All rights reserved.
//

#import "NSError+QNCentral.h"

@implementation NSError (QNCentral)

+ (NSError *)errorWithCode:(QNCentralCode)code {
    NSMutableDictionary *useInfo = [NSMutableDictionary dictionary];
    switch (code) {
        case QNCentralStateUnknownError: [useInfo setObject:@"The system bluetooth state is unknow" forKey:NSLocalizedDescriptionKey]; break;
        case QNCentralStateResettingError: [useInfo setObject:@"The system bluetooth state is resetting" forKey:NSLocalizedDescriptionKey]; break;
        case QNCentralStateUnsupportedError: [useInfo setObject:@"The system isn't support blue" forKey:NSLocalizedDescriptionKey]; break;
        case QNCentralStateUnauthorizedError: [useInfo setObject:@"The system isn't authorized use blue" forKey:NSLocalizedDescriptionKey]; break;
        case QNCentralStatePoweredOffError: [useInfo setObject:@"The system bluetooth is poweredOff" forKey:NSLocalizedDescriptionKey]; break;
        case QNCentralStateConnectFailError: [useInfo setObject:@"The peripheral connect fail" forKey:NSLocalizedDescriptionKey]; break;
        case QNCentralStatePeripheralHasConnectError: [useInfo setObject:@"The peripheral state didn't disconnect" forKey:NSLocalizedDescriptionKey]; break;
        case QNCentralResponseTimeover: [useInfo setObject:@"device response time over" forKey:NSLocalizedDescriptionKey]; break;

        default:
            break;
    }
    return [NSError errorWithDomain:QNCentralDomain code:code userInfo:useInfo];
}

@end
